import 'package:firebase_performance/firebase_performance.dart';

class MetricWrapper {
  final HttpMetric? _httpMetric;

  MetricWrapper(this._httpMetric);

  start() {
    _httpMetric?.start();
  }

  stop() {
    _httpMetric?.stop();
  }

  void putAttribute(String name, String value) {
    _httpMetric?.putAttribute(name, value);
  }

  /// HttpResponse code of the request.
  int? get httpResponseCode => _httpMetric?.httpResponseCode;

  /// Size of the request payload.
  int? get requestPayloadSize => _httpMetric?.requestPayloadSize;

  /// Content type of the response such as text/html, application/json, etc...
  String? get responseContentType => _httpMetric?.responseContentType;

  /// Size of the response payload.
  int? get responsePayloadSize => _httpMetric?.responsePayloadSize;

  /// HttpResponse code of the request.
  ///
  /// If the [HttpMetric] has already been stopped, returns immediately without
  /// taking action.
  set httpResponseCode(int? httpResponseCode) {
    _httpMetric?.httpResponseCode = httpResponseCode;
  }

  /// Size of the request payload.
  ///
  /// If the [HttpMetric] has already been stopped, returns immediately without
  /// taking action.
  set requestPayloadSize(int? requestPayloadSize) {
    _httpMetric?.requestPayloadSize = requestPayloadSize;
  }

  set responsePayloadSize(int? responsePayloadSize) {
    _httpMetric?.responsePayloadSize = responsePayloadSize;
  }

}